package le.ralph.quwen.cn.java.model.protocol;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class RetrofitManager {
    private Retrofit retrofit;
    private IHttpService httpService;

    private void initRetrofit() {
        retrofit = new Retrofit.Builder()
                .baseUrl(IHttpService.HOST_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        httpService = retrofit.create(IHttpService.class);
    }

    public Retrofit getRetrofit() {
        return retrofit;
    }

    public IHttpService getService() {
        return httpService;
    }

    private RetrofitManager() {
        initRetrofit();
    }
    private static class SingleHolder {
        public static RetrofitManager instance = new RetrofitManager();
    }

    public static RetrofitManager getInstance() {
        return SingleHolder.instance;
    }
}
